<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>租赁后台管理系统</title>
  <link rel="stylesheet" href="{{static_url('layui/css/layui.css')}}">
  <link rel="stylesheet" href="{{static_url('css/global.css')}}">
  <link rel="stylesheet" href="{{static_url('icheck/minimal/red.css')}}">

  <script type="text/javascript" src="{{static_url('js/jquery-1.8.3.min.js')}}"></script>
  <script type="text/javascript" src="{{static_url('javascript/jquery.min.js')}}"></script>
  <script type="text/javascript" src="{{static_url('layui/layui.js')}}"></script>
  <script type="text/javascript" src="{{static_url('icheck/icheck.js')}}"></script>
  <script type="text/javascript" src="{{static_url('javascript/index.js')}}"></script>
  <script type="text/javascript" src="{{static_url('javascript/dw.js')}}"></script>

</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

  {% include 'temp_nav.html' %}
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
        <fieldset class="layui-elem-field">
            <legend>发布申请</legend>

            <div class="layui-field-box">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="200">
                        <col>
                    </colgroup>
                    {% if resultViews == '0' %}

                    暂无申请
                    {% else %}
                    <thead>
                        <tr>
	                        <th>基本信息</th>
	                        <th>房东信息</th>
	                        <th>申请时间</th>
	                        <th>审核状态</th>
	                        <th>操作</th>
                        </tr> 
                    </thead>
                    <tbody>
                        {% for view in resultViews %}
                            <tr>
                                <td>{{view['renting_title']}}</td>
                                <td>{{view['user_name']}}：{{view['user_email']}}</td>
                                <td>{{view['release_time']}}</td>
                                <td>待审核</td>
                                <td>
                                    <!--<button class="layui-btn layui-btn-xs layui-btn-normal dw-dailog" dw_url="" title="" dw-width="40%" dw-height="40%">-->
                                        <!--<i class="layui-icon">&#xe642;</i><a href="/admin/houseApplyCheck?id={{view['renting_id']}}">查看</a>-->
                                    <!--</button>-->
                                    <button class="layui-btn layui-btn-xs layui-btn-normal dw-update"title="{{view['renting_id']}}">
                                        <i class="layui-icon">&#xe642;</i>通过
                                    </button>
                                    <button class="layui-btn layui-btn-xs layui-btn-danger dw-delete"  title="{{view['renting_id']}}">
                                        <i class="layui-icon">&#xe640;</i>不通过
                                    </button>
                                </td>
                            </tr>
                        {% end %}
                    </tbody>
                    {% end %}
                </table>
            </div>
        </fieldset>
    </div>
  </div>

  {% include 'temp_footer.html' %}

</div>

<script type="text/javascript" src="{{static_url('javascript/dw_form_submit.js')}}"></script>
<script type="text/javascript">
    $(function () {
        $('.dw-delete').click(function () {
            if(confirm('确定不通过吗？')){
                var title = $(this).attr('title');
                $.ajax({
                    type: 'POST',
                    url: '/admin/houseDelete',
                    data: {'renting_id': title},
                    dataType: 'json',
                    success: function (data) {
                        if(data.result == 'ok'){
                            layer.msg("已打回");
                            setTimeout(function () {
                                window.location.href = window.location.href;
                            }, 2000);
                        }else{
                            layer.msg('哪出错了吧');

                        }
                    },
                    error: function (data) {
                        layer.msg('网络出错，请稍后重试');
                    }
                });
            }
        });

        $('.dw-update').click(function () {
            if(confirm('确定通过吗？')){
                var title = $(this).attr('title');
                // alert(title);
                $.ajax({
                    type: 'POST',
                    url: '/admin/houseUpdate',
                    data: {'renting_id': title},
                    dataType: 'json',
                    success: function (data) {
                        if(data.result == 'ok'){
                            // alert('该用户发布的信息符合规范，已经允许通过！');
                            layer.msg('已通过');
                            setTimeout(function () {
                                window.location.href = window.location.href;
                            }, 2000);

                        }else{
                            layer.msg('哪出错了吧');
                        }
                    },
                    error: function (data) {
                        layer.msg('网络出错，请稍后重试');
                    }
                });
            }
        });
    });
</script>
</body>
</html>